﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="makehtml_index_page.aspx.cs" Inherits="yzadmin_makehtml_index_page" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="../Scripts/jquery.js"></script>
    <script src="../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/jquery.progressbar.min.js"></script>
    <script type="text/javascript">
        var zzlist = <%=zzlist %>;
        var today = <%=today %>;
        var i = 0;
        function createAll_onclick() {
            $.getJSON("/yzadmin/data/makehtml.aspx?a=author", { id: zzlist[i].id }, function (data) {
                if (data.success) {
                    i++;
                    $('#pball').progressBar(i,{ max: zzlist.length , textFormat: 'fraction', barImage: '../images/progressbar/progressbg_red.gif' });
                    if (i < zzlist.length) {
                        createAll_onclick()
                    }
                }
            });
        }

        $(document).ready(function() {
            $("#pball").progressBar({ max: zzlist.length , textFormat: 'fraction', barImage: '../images/progressbar/progressbg_red.gif' });
        });
        
        function createToday_onclick(){
            var i = 0;
            var createToday = function(){
                if (today[i] != null) {
                    $('#txttoday').html("正在更新" + today[i].name);
                    $('#pbtoday').progressBar(0,{ max: today[i].id.length , textFormat: 'fraction', barImage: '../images/progressbar/progressbg_red.gif' });
                    createTodayItems(0,today[i].id,today[i].url);
                }else {
                    $.ajax({
                        url:'/yzadmin/data/makehtml.aspx?a=index',
                        type:'POST',
                        success:function(){
                            $('#txttoday').html("生成完成");
                        }
                    });
                }
            }
            var createTodayItems = function(index,ids,url){
                $.ajax({
                    url:url + ids[index],
                    timeout:600000,
                    type:'POST',
                    dataType :'html',
                    success:function(data){
                        $('#pbtoday').progressBar(index + 1,{ max: today[i].id.length , textFormat: 'fraction', barImage: '../images/progressbar/progressbg_red.gif' });
                        if (index + 1 < ids.length) {
                            createTodayItems(index+1,ids,url);
                        }else {
                            i++
                            createToday();
                        }
                    }
                });
            }
            createToday();
        }
    </script>
    <style type="text/css">
        .style1 {
            width: 311px;
        }
    </style>
</head>
<body>
    <table width="98%" border="0" align="center" cellpadding="8" cellspacing="1" bgcolor="#CCCCCC">
        <tr>
            <td bgcolor="e7e7e7" colspan="2">
                <strong>批量生成</strong></td>
        </tr>
        <tr>
            <td bgcolor="#FFFFFF" class="style1">按时间
            </td>
            <td bgcolor="#FFFFFF">
                <span class="progressBar" id='pbtime'></span>
            </td>
        </tr>
        <tr>
            <td bgcolor="#FFFFFF" class="style1">生成当天 <input id="Button1" type="button" value="生成" onclick="return createToday_onclick()" /></td>
            <td bgcolor="#FFFFFF">
                <span id="txttoday"></span>
                <span class="progressBar" id='pbtoday'></span>
            </td>
        </tr>
        <tr>
            <td bgcolor="#FFFFFF" class="style1">生成全部作者
                <input id="createAll" type="button" value="生成" onclick="return createAll_onclick()" /></td>
            <td bgcolor="#FFFFFF">
                <span class="progressBar" id='pball'></span>
            </td>
        </tr>
    </table>
</body>
</html>
